package com.shop.service;

import java.util.List
;



import com.shop.dao.UserDaoImpl;
import com.shop.entity.User;



	

public class UserService {
	private UserDaoImpl UserDaoImpl = new UserDaoImpl();
	

	/**
	 * 判断用户名密码对应的数据是否存在
	 * 返回 true 存在， false不存在
	 */
	public boolean isExist(User user){
		return UserDaoImpl.isExist(user);
	}
	public boolean isExists(String username){
		return UserDaoImpl.findUserByUserName(username)==null? false:true;
	}
	/**
	 * 查询所有用户
	 */
	public List<User> getAllUser(){
		List<User> list = UserDaoImpl.getAllUser();
		return UserDaoImpl.getAllUser();
	}
	
	public User addUser(User user){
		 user=UserDaoImpl.addUser(user);
		 
		return user;
		
	}
	public User findUserById(int id) {
		User u = UserDaoImpl.findUserById(id);
		return u;
	}

	public boolean updateUser(User user) {
		boolean result=UserDaoImpl.updateUser(user);
		 if(result) {
			 return true;
		 }else {
			 return false;
		 }

	}
}
